import request from '/src/axios.js';
import {baseUrl} from "../../config/env";

export const roleApi = {
  getPage: (current, size, params) => request({
    url: baseUrl + '/api-user/roles/rolePage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  }),
  menuButtonTree: () => request({
    url: baseUrl + '/api-user/menus/menuButtonTree',
    method: 'get',
    // data: row
  }),
  grant: (roleIds, menuIds, dataScopeIds) => request({
    url: baseUrl + '/api-user/auth/granted',
    method: 'post',
    data: {
      roleId: roleIds[0],
      menuIds,
      dataScopeIds
    }
  }),
  remove: (ids) => request({
    url: baseUrl + '/api-user/roles/remove/' + ids,
    method: 'post',
    // params: {
    //   ids,
    // }
  }),
  create: (row) => request({
    url: baseUrl + '/api-user/roles/create',
    method: 'post',
    data: row
  }),
  update: (row) => request({
    url: baseUrl + '/api-user/roles/update',
    method: 'post',
    data: row
  }),
  selectedMenuByRoleId: (roleIds) => request({
    url: baseUrl + '/api-user/menus/selectedMenuByRoleId',
    method: 'get',
    params: {
      roleId: roleIds,
    }
  }),
  getRoleList: () => request({
    url: baseUrl + '/api-user/roles/roleList',
    method: 'get'
  })
}
